package com.cskaoyan.day2;

import java.util.Scanner;

public class OddNumber {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入数n：");
        int n = sc.nextInt();
        printOdd(n);
    }

    private static void printOdd(int n) {
        int sum = 0;
        for (int i = 1; i <= n; i++) {
            if (i % 2 != 0) {
                sum += i;
            }
        }
        System.out.println(n + "以内的奇数之和为:" + sum);
    }
}
